home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 36
/
PC Gamer IT CD 36 2-2.iso
/
VIGDEMO
/
data1.cab
/
Assets
/
scripts
/
machinegun.e
< prev
next >
Wrap
Text File
|
1998-09-21
|
6KB
|
757 lines
int Initialize(string type)
{
global int state ;
global real repeatTime = .3;
global int maxBullet = 200;
global int gBulletCount = 20;
global int hitValue = 1;
global int gGravity = 0;
global int gClipSize = 30;
global int gStartSound = 0;
global int gReloadSound = -1;
global int gEndSound = 19;
global int gStartSoundChannel;
global real gMass = 1.0;
global int mPrivileged;
Reset("dumy");
return 0;
}
int SetBulletCount(int count)
{
gBulletCount = count;
}
int startsound(string soundname)
{
gStartSound = GetSoundIndex(soundname);
}
int endsound(string soundname)
{
gEndSound = GetSoundIndex(soundname);
}
int reloadsound(string soundname)
{
gReloadSound = GetSoundIndex(soundname);
}
int Reset(string dummy)
{
state = 0;
SetCollidableProperties(thisObject,gGravity,0);
SetStyle(thisObject,2);
gBulletCount = gClipSize;
gStartSoundChannel = 0;
mPrivileged = 0;
SetScale(thisObject,2.0);
wakeupTime = -1.0;
return 0;
}
int clipsize(string count)
{
gClipSize = Str2Int(count);
gBulletCount = gClipSize;
}
int GetMaxAmmo(string dummy)
{
ReturnValue(thisObject, gClipSize);
}
int addammo(string count)
{
int value = Str2Int(count);
gBulletCount = gBulletCount + value;
}
int gravity(string flag)
{
int value;
value = Str2Int(flag);
gGravity = value;
SetCollidableProperties(thisObject,gGravity,0);
}
int damage(string str)
{
hitValue = Str2Int(str);
return 0;
}
int repeattime(string str)
{
repeatTime = Str2Real(str);
return 0;
}
int Colliders(string dummy)
{
map::iterator ix;
map objInList;
int value;
objInList = Collisions(thisObject,0,1,0);
for (ix = begin(objInList) ;ix != end(objInList); ++ix)
{
value = AddObjectTo(first(dereference(ix)),thisObject);
if (value != 0)
{
PlaySound(thisObject,35);
SetScale(thisObject,1.0);
break;
}
}
return 0;
}
int Launch(string dummy)
{
SetScale(thisObject,2.0);
}
int Drop(string dummy)
{
int returnBullet;
Launch(dummy);
FireStopFulfill(0);
SetCollidableProperties(thisObject,gGravity,0);
SetStyle(thisObject,2);
PlaySound(thisObject,38);
ReturnValue(thisObject,0);
}
int reload(string count)
{
int add;
add = Str2Int(count);
if (add > 0)
{
PlaySound(thisObject,gReloadSound);
gBulletCount += add;
}
}
int AmmoCount(string dum)
{
ReturnValue(thisObject,gBulletCount);
}
int Draw(string ammoCount)
{
gBulletCount = Str2Int(ammoCount);
}
int Pickup(string dummy)
{
mPrivileged = 0;
ReturnValue(thisObject,gBulletCount);
gBulletCount = 0;
}
int Holster(string dummy)
{
ReturnValue(thisObject,gBulletCount);
gBulletCount = 0;
}
int HitTheTarget()
{
Animate(thisObject,1,"fire");
LaunchBeam(thisObject,0,1.0,3.0,"tracer",0.25,0.75);
LaunchMuzzleFlash(thisObject);
ParentFire(thisObject);
if (GetHit(thisObject) == 1)
{
HitTarget(thisObject,hitValue);
}
else
{
MakeDecal(thisObject,1,0);
PlaySound(thisObject,gEndSound,1);
}
}
int GetFireTime(string dummy)
{
ReturnValueReal(thisObject,repeatTime);
return 0;
}
int SetBulletCount(int count)
{
gBulletCount = count;
}
int FireFulfill(int notused)
{
state = 2;
TimedEvent(0);
gStartSoundChannel = PlaySound(thisObject,gStartSound,0,1);
}
int Fire(int flag)
{
real time ;
int retValue = 0;
time = GetTime(thisObject);
mPrivileged = 0;
if (UnlimitedAmmo(thisObject) == 1)
gBulletCount = gClipSize;
if (state == 0)
{
{
if (gBulletCount >= 1)
{
mPrivileged = 1;
state = 2;
FireSaveInfo(thisObject,hitValue,gBulletCount,gMass);
FireCommand(thisObject);
retValue = 1;
}
else
{
ParentReloadCommand(thisObject);
}
}
}
ReturnValue(thisObject,retValue);
return 0;
}
int FireStopFulfill(int whatever)
{
if (gStartSoundChannel != 0)
StopSound(thisObject,gStartSoundChannel);
state = 0;
TimedEvent(1);
}
int FireStop(string dummy)
{
FireStopRequest(thisObject);
}
int TimedEvent(int input)
{
real time = GetTime(thisObject);
int hit;
if (UnlimitedAmmo(thisObject) == 1)
gBulletCount = gClipSize;
switch (state)
{
case 2:
if (gBulletCount > 0)
{
gBulletCount--;
if (mPrivileged == 1)
FireSaveInfo(thisObject,hitValue,gBulletCount,gMass);
HitTheTarget();
wakeupTime = time + repeatTime;
}
else
{
if (gStartSoundChannel != 0)
StopSound(thisObject,gStartSoundChannel);
state = 0;
wakeupTime = -1.0;
}
break;
case 0:
state = 0;
Animate(thisObject,0,"fire");
wakeupTime = -1.0;
break;
}
return 0;
}